<template>
  <div class="wrap">
    <el-form class="login-form" ref="form" :model="form" label-width="80px">
      <el-form-item label="用户名">
        <el-input v-model="form.username"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="form.password"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">登陆</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form: {
        username: "",
        password: "",
      },
    };
  },
  methods: {
    onSubmit() {
      if (this.form.username == "admin" && this.form.password == "123456") {
        localStorage.setItem("token", this.form.username);
        this.$router.push("/goods");
      } else {
        this.$message({
          message: "警告哦，用户名或者密码错误",
          type: "warning",
        });
      }
    },
  },
  created() {},
  mounted() {},
  components: {},
  computed: {},
  watch: {},
};
</script>

<style lang="scss" scoped>
.wrap {
  width: 100vw;
  height: 100vh;
  background: rgb(49, 62, 95);
  display: flex;
  justify-content: center;
  align-items: center;
  .login-form {
    width: 300px;
  }
}
</style>
